<?php
	if(!defined("IN_APP"))
	{
		exit;
	}
	
	$parm = requestArrayParm($_REQUEST);
	
	$method = getParam('m','get','list');
	
	if($method == 'tiaozhuan')
	{
		if(!empty($parm['id']))
		{
			unset($wheres);
			$wheres['id'] = $parm['id'];
			$wheres['status'] = '1';
			$item = _ChanPin::getChanPin_ItemInfo($wheres);
			if($item)
			{
				$chanpin_id = $item['pid'];
				$item_id =$item['id'];
				$tongji_type = 'item';
				
				require_once(ROOTDIR.'source/model/tongji.php');
		
				header('HTTP/1.1 301 Moved Permanently');
				header("Location: ".$item['link']);
				exit;
			}
			else
			{
				header("Location:$befor");
			}
		}
		else
		{
			header("Location:$befor");
		}
	}
	
	
	if($method == 'list')
	{
		if(!empty($parm['id']))
		{	
			unset($wheres);
			$wheres['id'] = $parm['id'];
			$wheres['status'] = '2';
			$chanpin = _ChanPin::getChanPinInfo($wheres);
			if(!empty($chanpin))
			{
				$chanpin_id = $chanpin['id'];
				//$item_id =$item['id'];
				$tongji_type = 'chanpin';
				
				require_once(ROOTDIR.'source/model/tongji.php');
			
				unset($wheres,$sort,$pages);
				$wheres['pid'] = $parm['id'];
				$wheres['status'] = '1';
				$sort['sort'] = 'desc';
				$sort['addtime'] = 'desc';
				$resData = _ChanPin::getChanPin_ItemList($wheres, array(), $sort);
				$list = $resData;
				
				include renderTemplate('index/product');
			}
			else
			{
				header("Location:".SITE_URL.'index.php');
			}
		}
		else
		{
			header("Location:".SITE_URL.'index.php');
		}
	}
	
	
	
	
	